package org.jetlinks.pro.equipment.entity;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;
import org.hswebframework.ezorm.rdb.mapping.annotation.DefaultValue;
import org.hswebframework.web.api.crud.entity.GenericEntity;
import org.hswebframework.web.crud.generator.Generators;
import org.hswebframework.web.validator.CreateGroup;

import javax.persistence.Column;
import javax.persistence.Index;
import javax.persistence.Table;
import javax.validation.constraints.NotBlank;
import java.util.Date;

@Getter
@Setter
@Table(name = "k_equipment",indexes = {
        @Index(name = "idx_equipment_id",columnList = "id")
})
public class EquipmentEntity extends GenericEntity<String> {

    @Column(length = 32)
    @NotBlank(message = "[key]不得为空",groups = CreateGroup.class)
    @Schema(description = "设备出厂时间")
    private String factoryTime;

    @Column(length = 64)
    @NotBlank(message = "[key]不得为空",groups = CreateGroup.class)
    @Schema(description = "设备批次")
    private String batch;

    @Column(length = 64)
    @NotBlank(message = "[key]不得为空",groups = CreateGroup.class)
    @Schema(description = "芯片ID")
    private String chipId;

    @Column(length = 64)
    @NotBlank(message = "[key]不得为空",groups = CreateGroup.class)
    @Schema(description = "设备厂商")
    private String vendor;

    @Column(updatable = false)
    @DefaultValue(generator = Generators.CURRENT_TIME)
    @Schema(description = "设备录入系统时间")
    private Date systemTime;

    @Column
    @DefaultValue(generator = Generators.CURRENT_TIME)
    @Schema(description = "设备更新时间")
    private Date updateTime;

    @Column
    @DefaultValue(value = "0")
    private Integer mostUsers;

    /**
     * 1、正常 2、禁用
     */
    @Column
    @DefaultValue(value = "1")
    @Schema(description = "设备的状态")
    private Integer status;

    @Column(length = 64)
    @NotBlank(message = "[key]不能为空")
    @Schema(description = "设备所属的学校")
    private String schoolBy;
}
